package InvestmentPojo;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import ImmovableIndia.ConnectionPool;



public class SiteAdminPrevilegesAction extends Action {

	  ConnectionPool pool=null;
	  public ActionForward execute(ActionMapping mapping, ActionForm inForm, HttpServletRequest request, HttpServletResponse response) throws Exception {
		 
		  
		 
		  String notificationNumber = request.getParameter("NotificationNumber");
		  String dateofNotification = request.getParameter("DateofNotification");
		  String subjectMatter = request.getParameter("SubjectMatter");
		  String effectivedate = request.getParameter("Effectivedate");
		  Connection con=null;
		  Statement st=null;
		  
		  System.out.println("notificationNumber"+notificationNumber+"dateofNotification"+dateofNotification+"subjectMatter"+subjectMatter+"effectivedate"+effectivedate);
		  try{
		  //Connection-Starts.
		  con=getConnection();
		  st=con.createStatement();
			
			st.executeUpdate("insert  into `notification`(`serviceno`," +
							"`Notification No`,`Date of Notification`,`subject Mater`,"+
							"`Effective Date`,`modified By`,`modified On`,`createdby`,`created on`)"+
							" values" + 
							" (3,'"+notificationNumber+"','"+dateofNotification+"','"+subjectMatter+"','"+effectivedate+"','admin','2013-06-11','admin','2013-06-11')");
			
		  //Connection-Ends.
		  }catch(Exception e){
			  con.rollback();
			  e.printStackTrace();
		  }finally{
			  try {
					if(null != st)
						pool.releaseResources(st);
					System.out.println("Connection ST closed........--------------");
					if(null != con)
					pool.releaseConnection(con);
					System.out.println("Connection con closed........--------------");
				} catch (Exception e) {
					e.printStackTrace();
				}
		  }
		  return mapping.findForward("succ"); // Not forwarding to anywhere, response is fully-cooked
	    
	  }
	  public Connection getConnection() throws SQLException, Exception {
			pool=new ConnectionPool();
			return pool.getConnection();
	}
}
